package classification;
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class ClassificationMapper  extends Mapper<Object, Text, Text, Text> {

    private static final String VILLAGE_CONTACTS_HEADER = "新村名称,管区书记,管区区长,分管领导";

    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        if (line.startsWith(VILLAGE_CONTACTS_HEADER) || line.trim().isEmpty()) {
            return; // Skip header and empty lines
        }
        String[] data = line.split(",");
        if (data.length >= 4 && VILLAGE_CONTACTS_HEADER.equals(data[0])) {
            context.write(new Text(data[0]), new Text(line));
        }
    }
}
